package com.kyrie.lib_sys.application.timeApplys.controller;


import com.google.common.base.Preconditions;
import com.kyrie.lib_sys.application.timeApplys.pojo.dto.TimeListDTO;
import com.kyrie.lib_sys.application.timeApplys.service.TimeListService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/timeList")
public class TimeListController {

    @Autowired
    private TimeListService timeListService;

    @PutMapping("/validate")
    public String validateTimeList(@RequestBody TimeListDTO timeListDTO) {
        log.info("开始校验时间列表(单个dto)Controller: {}", timeListDTO);
        //checkNotNull 适合校验对象  checkAugments 适合校验参数()
        timeListService.validateTimeList(timeListDTO);
        return "校验成功";
    }

    @PutMapping("/validateList")
    public String validateList(@RequestBody List<TimeListDTO> timeListDTO) {

        log.info("开始校验时间列表(dto集合)Controller: {}", timeListDTO);
        //checkNotNull 适合校验对象  checkAugments 适合校验参数()
        Preconditions.checkNotNull(timeListDTO);

        timeListService.validateList(timeListDTO);
        return "校验成功,已保存数据";
    }



}

